#include "addeventwindow.h"
#include "ui_addeventwindow.h"
#include <QMessageBox>
#include <QDebug>

AddEventWindow::AddEventWindow(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::AddEventWindow)
{
    ui->setupUi(this);

    // 设置下拉框的items
    ui->isTopFiveComboBox->addItem("是");
    ui->isTopFiveComboBox->addItem("否");
    ui->isMaleComboBox->addItem("是");
    ui->isMaleComboBox->addItem("否");
}

AddEventWindow::~AddEventWindow()
{
    delete ui;
}

void AddEventWindow::on_addButton_clicked()
{
    qDebug() << "Add button clicked";

    QString name = ui->nameLineEdit->text();
    int isTopFive = ui->isTopFiveComboBox->currentIndex();
    bool isMale = ui->isMaleComboBox->currentIndex() == 0;
    if (!name.isEmpty()) {
        emit eventAdded(name, isTopFive, isMale);
        QMessageBox::information(this, "提示", "项目添加成功");
    } else {
        QMessageBox::warning(this, "警告", "项目名称不能为空");
    }
}
